package com.wzw.springboot.principle.use.security.repository;

import com.wzw.springboot.principle.use.security.entity.UserRoleEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author Wangzhiwen
 */
public interface UserRoleRepository extends JpaRepository<UserRoleEntity, Long> {

    UserRoleEntity findByUserIdAndRoleId(Long userId, Long roleId);

    List<UserRoleEntity> findAllByRoleId(Long roleId);

    @Query(nativeQuery = true, value = "SELECT * FROM USER_ROLE WHERE USER_ID = ?1")
    List<UserRoleEntity> findByUserId(Long userId);

}
